package 线程.day3.demo3;

public class Sell implements Runnable{
    static int num=1000;

    @Override
    public void run() {
        while (num>0){

            //synchronized (Sell.class){
            sell();
            Thread.yield();

        }
    }
    synchronized static void sell(){
        if(num<=0){
           return;
        }
        System.out.println(Thread.currentThread().getName()+"卖出票："+num);
        num--;
    }
}
